# -*- coding: utf-8 -*-

# 把数字按照下图规律去排列，设1的坐标是(0, 0),  x方向向右为正，y方向向下为正。例如： 2的坐标是(1,0), 3的坐标是(1,1),  7的坐标为 (-1, -1)
# 请实现函数：
# 输入是任意坐标(x,y)， 输出所对应的数字
# 21  22 23 24 25 26
# 20  7  8  9  10
# 19  6  1  2  11
# 18  5  4  3  12
# 17 16 15 14  13

def getNum(x, y):
    x_step = 2 * x - 1 if x > 0 else -2 * x;
    y_step = 2 * y - 1 if y > 0 else -2 * y;
    # print "step:";
    # print [x, y], [x_step, y_step];
    ans = 0;
    if y_step >= x_step:
        # x轴先走
        ans = y_step * y_step + y_step;
        begin = -1 * y_step // 2 if y_step % 2 == 0 else -1 * (y_step // 2) + y_step;
        # print "->1 ans:";
        # print [ans, begin];
        ans += abs(x - begin);
    else:
        # y轴后走
        ans = (x_step - 1) * (x_step - 1) + (x_step - 1) + x_step;
        begin = -1 * x_step // 2 if x_step % 2 == 0 else -1 * (x_step // 2) + y_step;
        # print "->2 ans:";
        # print [ans, begin];
        if x_step != y_step + 1:
            ans += abs(y - begin);
    return ans;

test_list = [[0,0,0], [1,0,1],[1,1,2],[0,1,3],[-1,1,4],[-1,0,5],[-1,-1,6],[0,-1,7],[1,-1,8]];
for v in test_list:
    if v[2] != getNum(v[0], v[1]):
        print v;
        break;
    else:
        print ".";


